package org.practice.chart;
import java.util.Map;

public class ColumnChart extends FusionChart {
    /**标签<graph></graph>中定义的属性*/
    private String alternateHGridAlpha="30";
    private String alternateHGridColor="CCCCCC";
    private String divLineColor="CCCCCC";
    private String divLineAlpha="80";
    private String decimalPrecision="1";
    private String hovercapbg="DEDEBE";
    private String hovercapborder="889E6D";
    private String outCnvBaseFontSize="18";
    private String rotateNames="0";
    private String showAlternateHGridColor="1";
    private String showNames="";
    private String showhovercap="";
    private String xAxisName="";
    private String yAxisName="";


    private Map<String,String[]> dataMap;
	public ColumnChart(){
		
	}
	public ColumnChart(String...attr){
		
	}

    /**
     * @param caption 标题
     * @param attr 可变参数，个数为零或者多个
     */
	public ColumnChart(String caption,String...attr){
        this.caption=caption;
	}

    public ColumnChart(String caption){
        this.caption=caption;
    }

    /**
     * FusionChartsProp:简单属性
     * @param caption
     * @param attr
     */
    public ColumnChart(String caption,FusionChartsPropConst...attr){
        this.caption=caption;
    }

    /**
     *
     * 拼装的数据
     * @return 返回图表XML字符串
     */
    @Override
    public String generateXML(){
        String categoriesProps=null;
        if(dataMap.containsKey("categoriesProps")){
            categoriesProps=dataMap.remove("categoriesProps")[0];
        }else {
            categoriesProps="font='Arial' fontSize='12' fontColor='000000'";
        }
        StringBuffer xml=new StringBuffer(DataTransferUtil.getChartsTitleXml(this));
        xml.append(DataTransferUtil.getChartsCategoriesXml(dataMap.get("categories"),categoriesProps));
        xml.append(DataTransferUtil.getChartsDatasetXml(dataMap,dataMap.remove("datasetProperties")));
        return xml.append("</graph>").toString();
    }

    @Override
    public String generateXML(Map<String,String[]> dataMap){
        /*StringBuffer xml=new StringBuffer(DataTransferUtil.getChartsTitleXml(this));
        xml.append(DataTransferUtil.getChartsCategoriesXml(dataMap.get("categories")));
        xml.append(DataTransferUtil.getChartsDatasetXml(dataMap));
        return xml.append("</graph>").toString();*/
        return null;
    }

    public Map<String, String[]> getDataMap() {
        return dataMap;
    }

    public void setDataMap(Map<String, String[]> dataMap) {
        this.dataMap = dataMap;
    }
}
